<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>控制流分析报告</title>
    <style>
        body {
            margin: 0;
            padding: 20px;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: #f5f5f5;
            color: #333;
            line-height: 1.6;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            padding: 30px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
            padding-bottom: 20px;
            border-bottom: 2px solid #eee;
        }
        .header h1 {
            margin: 0;
            color: #2196F3;
            font-size: 28px;
        }
        .section {
            margin-bottom: 30px;
            padding: 20px;
            background-color: #f8f9fa;
            border-radius: 6px;
        }
        .section h2 {
            margin-top: 0;
            color: #333;
            font-size: 20px;
            border-bottom: 2px solid #e0e0e0;
            padding-bottom: 10px;
        }
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        .stat-card {
            background-color: white;
            padding: 15px;
            border-radius: 6px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .stat-card h3 {
            margin: 0;
            color: #666;
            font-size: 14px;
            text-transform: uppercase;
        }
        .stat-card p {
            margin: 10px 0 0;
            font-size: 24px;
            font-weight: 500;
            color: #2196F3;
        }
        .path-stats {
            margin-top: 20px;
        }
        .path-stat {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px;
            background-color: white;
            border-radius: 4px;
            margin-bottom: 10px;
        }
        .path-stat:last-child {
            margin-bottom: 0;
        }
        .path-label {
            font-weight: 500;
            color: #333;
        }
        .path-value {
            font-size: 18px;
            color: #2196F3;
        }
        .complexity-stats {
            margin-top: 20px;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
        }
        .complexity-stat {
            background-color: white;
            padding: 15px;
            border-radius: 4px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .complexity-stat h3 {
            margin: 0;
            font-size: 14px;
            color: #666;
        }
        .complexity-stat p {
            margin: 5px 0 0;
            font-size: 24px;
            font-weight: 500;
            color: #2196F3;
        }
        .problem-list {
            margin-top: 20px;
        }
        .problem-item {
            background-color: white;
            padding: 15px;
            margin-bottom: 15px;
            border-radius: 6px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }
        .problem-item:last-child {
            margin-bottom: 0;
        }
        .problem-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .problem-title {
            font-weight: 500;
            color: #f57c00;
        }
        .problem-type {
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
        }
        .type-complexity {
            background-color: #e3f2fd;
            color: #1976d2;
        }
        .type-nesting {
            background-color: #fff3e0;
            color: #f57c00;
        }
        .type-loop {
            background-color: #fce4ec;
            color: #c2185b;
        }
        .problem-details {
            margin-top: 10px;
            padding-top: 10px;
            border-top: 1px solid #eee;
        }
        .problem-details p {
            margin: 5px 0;
            color: #666;
        }
        .recommendation {
            margin-top: 10px;
            padding: 10px;
            background-color: #f5f5f5;
            border-radius: 4px;
        }
        .recommendation h4 {
            margin: 0;
            color: #333;
            font-size: 14px;
        }
        .recommendation p {
            margin: 5px 0 0;
            color: #666;
        }
        .footer {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 2px solid #eee;
            text-align: center;
            color: #666;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>控制流分析报告</h1>
        </div>
        
        <div class="section">
            <h2>节点统计</h2>
            <div class="stats-grid">
                <div class="stat-card">
                    <h3>节点总数</h3>
                    <p>{节点统计[总数]}</p>
                </div>
                <div class="stat-card">
                    <h3>条件节点</h3>
                    <p>{节点统计[条件节点]}</p>
                </div>
                <div class="stat-card">
                    <h3>循环节点</h3>
                    <p>{节点统计[循环节点]}</p>
                </div>
                <div class="stat-card">
                    <h3>顺序节点</h3>
                    <p>{节点统计[顺序节点]}</p>
                </div>
            </div>
        </div>
        
        <div class="section">
            <h2>路径统计</h2>
            <div class="path-stats">
                <div class="path-stat">
                    <span class="path-label">总路径数</span>
                    <span class="path-value">{路径统计[总路径数]}</span>
                </div>
                <div class="path-stat">
                    <span class="path-label">条件分支</span>
                    <span class="path-value">{路径统计[条件分支]}</span>
                </div>
                <div class="path-stat">
                    <span class="path-label">循环路径</span>
                    <span class="path-value">{路径统计[循环路径]}</span>
                </div>
                <div class="path-stat">
                    <span class="path-label">顺序路径</span>
                    <span class="path-value">{路径统计[顺序路径]}</span>
                </div>
            </div>
        </div>
        
        <div class="section">
            <h2>复杂度分析</h2>
            <div class="complexity-stats">
                <div class="complexity-stat">
                    <h3>总复杂度</h3>
                    <p>{复杂度统计[总复杂度]}</p>
                </div>
                <div class="complexity-stat">
                    <h3>平均复杂度</h3>
                    <p>{复杂度统计[平均复杂度]:.2f}</p>
                </div>
                <div class="complexity-stat">
                    <h3>最大复杂度</h3>
                    <p>{复杂度统计[最大复杂度]}</p>
                </div>
                <div class="complexity-stat">
                    <h3>最小复杂度</h3>
                    <p>{复杂度统计[最小复杂度]}</p>
                </div>
            </div>
        </div>
        
        <div class="section">
            <h2>问题节点分析</h2>
            <div class="problem-list">
                <!-- 由JavaScript动态填充 -->
            </div>
        </div>
        
        <div class="footer">
            <p>生成时间: <span id="timestamp"></span></p>
        </div>
    </div>
    
    <script>
        // 设置生成时间
        document.getElementById('timestamp').textContent = new Date().toLocaleString();
        
        // 填充问题节点信息
        const problems = {问题节点};
        const problemList = document.querySelector('.problem-list');
        
        if (problems.length === 0) {
            problemList.innerHTML = '<p style="text-align: center; color: #666;">未发现问题节点</p>';
        } else {
            problems.forEach((problem, index) => {
                const typeClass = 
                    problem.类型 === '复杂度过高' ? 'type-complexity' :
                    problem.类型 === '嵌套过深' ? 'type-nesting' : 'type-loop';
                    
                const div = document.createElement('div');
                div.className = 'problem-item';
                div.innerHTML = `
                    <div class="problem-header">
                        <span class="problem-title">问题 #${index + 1}</span>
                        <span class="problem-type ${typeClass}">${problem.类型}</span>
                    </div>
                    <div class="problem-details">
                        <p><strong>节点:</strong> ${problem.节点}</p>
                        <p><strong>描述:</strong> ${problem.描述}</p>
                        <div class="recommendation">
                            <h4>优化建议</h4>
                            <p>${problem.建议}</p>
                        </div>
                    </div>
                `;
                
                problemList.appendChild(div);
            });
        }
    </script>
</body>
</html> 